//
//  AppDelegate.m
//  videoTest3
//
//  Created by jun peng on 2022/5/27.
//

#import "AppDelegate.h"
#import "YWTabBarController.h"
#import "YWDownloadManager3.h"

@interface AppDelegate ()

@end

@implementation AppDelegate
//此方法会在设备横竖屏变化的时候调用、因为一开始_allowRotate是0，所以一开始是竖屏
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    
    //   NSLog(@"方向  =============   %ld", _allowRotate);
    if (_allowRotate == 1) {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }else{
        return (UIInterfaceOrientationMaskPortrait);
    }
}


// 返回是否支持设备自动旋转
- (BOOL)shouldAutorotate
{
    if (_allowRotate == 1) {
        return YES;
    }
    return NO;
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   
    
    application.statusBarHidden = NO;
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    
    self.window.rootViewController = [[YWTabBarController alloc] init];
    
    
    [self.window makeKeyAndVisible];
    
    //一进来App就开启下载任务
    YWDownloadManager3 *manager = [YWDownloadManager3 sharedownloadManager];
    [manager beginDataTask];
    
    return YES;
}




- (void)applicationWillResignActive:(UIApplication *)application {

}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:YWEnterBackgroundNote object:self userInfo:nil];
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:YWEnterForegroundNote object:self userInfo:nil];
}


- (void)applicationDidBecomeActive:(UIApplication *)application {

}


- (void)applicationWillTerminate:(UIApplication *)application {

    
}

@end
